package org.feuyeux.quarkus.hello;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import lombok.extern.slf4j.Slf4j;

@Path("/hello")
@Slf4j
public class GreetingResource {

    @Inject
    private GreetingService greetingService;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("{name}")
    public String greetingPath(@PathParam("name") String name) {
        log.info("path: {}", name);
        return greetingService.politeHello(name);
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public String greetingQuery(@DefaultValue("RESTEasy") @QueryParam("name") String name) {
        if (!"RESTEasy".equals(name)) {
            log.info("query: {}", name);
        }
        return "Hello " + name;
    }
}